﻿using System;
using System.Collections.Generic;
using System.Linq;
using System.Text;
using System.IO;
using System.Threading;
using System.Windows.Forms;

namespace FBGASaveData
{/*
    public class FileSaveData
    {
        private FileStream _fs = null;
        private DateTime _startTime = DateTime.Now;
        private string curFileName = string.Empty;

        public void SaveData(object o)
        {
            try
            {
                byte[][] bufferArray = o as byte[][];
                if (this.curFileName == string.Empty)
                {
                    this._startTime = DateTime.Now;
                    this.curFileName = string.Format("{0}.dat", this._startTime.ToString("yyyyMMddHHmm"));
                }
                if (this._startTime.AddHours(1.0) <= DateTime.Now)
                {
                    this._startTime = DateTime.Now;
                    this.curFileName = string.Format("{0}.dat", this._startTime.ToString("yyyyMMddHHmm"));
                }
                if (!File.Exists(CGlobal.FilePath + this.curFileName))
                {
                    if (this._fs != null)
                    {
                        this._fs.Close();
                        this._fs.Dispose();
                        this._fs = null;
                    }
                    this._fs = File.OpenWrite(CGlobal.FilePath + this.curFileName);
                    CGlobal.dtFileStart = _startTime;
                }
                if (this._fs != null)
                {
                    foreach (byte[] buffer in bufferArray)
                    {
                        this._fs.Write(buffer, 0, buffer.Length);
                    }
                    CGlobal.lCurReceiveLength = _fs.Position;
                }
            }
            catch (ThreadAbortException)
            {
            }
            catch (Exception exception2)
            {
                File.AppendAllText(Application.StartupPath + @"\Eor.log", string.Format("{0}  {1}:{2}\r\n", DateTime.Now, exception2.StackTrace, exception2.Message));
            }
        }
    }
      * */
}

